<template>
  <div class="head">
    <div class="head-wrapper">
      <div class="head-wrapper-left">
        <span class="head-wrapper-left-day">{{day}}</span>
        <span class="head-wrapper-left-month">{{month}}</span>
      </div>
      <div class="head-wrapper-title">
        <h2>{{now}} !</h2>
      </div>
      <div class="head-wrapper-right">
        <img class="avatar" src="~@/assets/images/tou.jpg" alt="头像" />
      </div>
    </div>
  </div>
</template>

<script>
import {getDay, getMonth, getTimeNow} from '@/utils/time'
import { reactive, toRefs } from 'vue'
export default {
  name: 'HomeHead',
  setup() {
    let time = reactive({
      day: getDay(),
      month: getMonth(),
      now: getTimeNow()
    })
    
    return {
      ...toRefs(time)
    }
  }
}
</script>

<style lang='less' scoped>
.head {
  position: fixed;
  width: 100%;
  background-color: #fff;
  box-shadow: 0 4px 2px -2px rgba(0, 0, 0, .1);
  z-index: 99;
}
.head-wrapper {
  display: flex;
  height: 46px;
  padding: 8px 15px;
  &-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding-right: 15px;
    border-right: 2px solid #ccc;
    &-day {
      display: block;
      margin-bottom: 5px;
      font-size: 20px;
      font-weight: 700;
    }
    &-month {
      font-size: 12px;
    }
  }
  &-title {
    flex: 1;
    padding-left: 15px;
    h2 {
      margin: 0;
      line-height: 46px;
      font-size: 20px;
    }
  }
  &-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    .avatar {
      width: 36px;
      border-radius: 50%;
    }
  }
}
</style>